<template>
  <div>
    <van-nav-bar
      fixed
      placeholder
      safe-area-inset-top
      title="推送房源"
      @click-left="back"
    >
      <template #left>
        <van-icon name="arrow-left" size="16px" color="#333" />
      </template>
    </van-nav-bar>
    <div v-show="houselist.length == 0" class="content">
      <img src="../../assets/nohouse.png" alt="" />
      <div>暂无房源推送信息</div>
    </div>
    <div
      v-show="houselist.length != 0"
      @click="jumptodetail(item.roomId, item)"
      v-for="item in houselist"
      :key="item.index"
      class="house"
    >
      <img :src="item.image" alt="" />
      <div class="intrduce">
        <span class="title1">{{ item.subdistrict }}</span>
        <span class="title2"
          ><span>{{ item.rentalWay }}</span
          >|<span>{{ item.houseType }}</span
          >|<span>{{ item.roomAcre }}</span
          >|<span>{{ item.floor }}</span></span
        >
        <span v-show="item.distance" class="title2"
          ><van-icon name="location" />{{ item.distance }}</span
        >
        <div class="tips">
          <span>{{ item.rentalWay }}</span>
          <span>{{ item.paymentMethod }}</span>
          <span>{{ item.houseType }}</span>
        </div>
        <span class="title3">{{ item.price }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import local from "../../utils/local";
export default {
  data() {
    return {
      houselist: [],
    };
  },
  methods: {
    back() {
      this.$router.go(-1);
    },
    jumptodetail(e, item) {
      let list = JSON.parse(local.get("todayhouselist"));
      for (let i = 0; i < list.length; i++) {
        if (list[i].roomId == item.roomId) {
          list.splice(i, 1);
        }
      }
      list.unshift(item);
      local.set("todayhouselist", JSON.stringify(list));
      local.set("roomId", e);
      this.$router.push({ path: "/housedetail" });
    },
  },
};
</script>

<style lang="less" scoped>
.content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  img {
    width: 130px;
    margin-top: 30px;
    margin-bottom: 30px;
  }
}
.house {
  display: flex;
  margin: 10px 15px;
  img {
    width: 120px;
    height: 110px;
  }
  .intrduce {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-left: 15px;
    .title1 {
      font-size: 16px;
      font-weight: 550;
      color: #333333;
    }
    .title2 {
      font-size: 12px;
      color: #a0a0a0;
      span {
        margin: 0 2px;
      }
    }
    .tips {
      span {
        font-size: 10px;
        display: inline-block;
        margin-right: 5px;
        padding: 2px;
        background-color: #ebfafd;
        color: #4daac1;
      }
    }
    .title3 {
      color: #d43b33;
      font-size: 16px;
      font-weight: bold;
      span {
        font-size: 12px;
        margin-left: 3px;
      }
    }
  }
}
</style>